<!--suppress ALL -->
<include file="./Template/header.html" />
<link rel="stylesheet" type="text/css" href="/Template/css/workflow.css">
<script type="text/javascript">

    $(function() {

        //初始化页面配置
        initPage("我的工单");

        //日期插件
        var start = document.getElementById('startdate');
        start.onfocus = function(){
            this.removeAttribute('placeholder');
        };
        start.onblur = function(){
            if(this.value == '') this.setAttribute('placeholder','开始日期');
        };

        var end = document.getElementById('enddate');
        end.onfocus = function(){
            this.removeAttribute('placeholder');
        };
        end.onblur = function(){
            if(this.value == '') this.setAttribute('placeholder','结束日期');
        };



        var app = new Vue({
            el: '#container',
            data: {
                orderList: [],
            },
            methods: {
                payInfo: function(id) {
                    window.location.href = "/wechat/userCenter/payInfo/id/"+id;
                },
                addWorkorder: function() {
                    var confirmMsg;
                    if($("#workorderType").val() == 1){
                        confirmMsg = confirm("确认添加新的AFO工单？");
                    }
                    if($("#workorderType").val() == 2){
                        confirmMsg = confirm("确认添加新的脊柱矫形器工单？");
                    }
                    if($("#workorderType").val() == 3){
                        confirmMsg = confirm("确认添加新的脑瘫常规物理检查表？");
                    }
                    if(confirmMsg == true){
                        window.location.href = "/wechat/workflow/addWorkorder?type="+$("#workorderType").val();
                    }else{
                        return false;
                    }
                },
                editWorkorder: function(id) {
                    window.location.href = "/wechat/workorder/index/id/"+id;
                },
                dateSearch: function() {
                    var status;
                    $("#my-order ul li").each(function() {
                        if($(this).hasClass("active")) {
                            status = $(this).attr("data-status");
                        }
                    });
                    getOrderList(status);
                },
                dateRefresh: function(str){
                    var start = document.getElementById('startdate');
                    start.value = '';
                    start.setAttribute('placeholder','开始日期');

                    var end = document.getElementById('enddate');
                    end.value = '';
                    end.setAttribute('placeholder','结束日期');
                    var status;
                    $("#my-order ul li").each(function() {
                        if($(this).hasClass("active")) {
                            status = $(this).attr("data-status");
                        }
                    });
                    getOrderList(status);
                },
                getItem: function(str, index){
                    var arr = str.split(',');
                    return arr[index];
                },
            }
        })

        function getOrderList(status) {

            $.ajax({
                url:"/wechat/Workorder/workorderList",
                type:"post",
                data:{
                    workorderType: $("#workorderType").val(),
                    status: status,
                    startdate: $("#startdate").val(),
                    enddate: $("#enddate").val()
                },
                dataType:"JSON",
                beforeSend:function(){
                    $("#loadingToast").show();
                },
                complete:function(){
                    $('#loadingToast').hide();
                },
                success:function(data){
                    app.orderList = data;
                    setTimeout(function() {
                        $(".ui-item.measure-info img").bind("click", function() {
                            var upUrl = "/Template/images/icon-up.png";
                            var downUrl = "/Template/images/icon-down.png";
                            $(this).parent().next().toggle();
                            if($(this).attr("src") == upUrl) {
                                $(this).attr("src", downUrl);
                            } else {
                                $(this).attr("src", upUrl);
                            }
                        });
                        $(".ui-item.measure-info img").each(function() {
                            $(this).trigger("click");
                        });
                    },200);
                },
            })
        }

        $("#my-order ul li").bind("click", function() {

            if($(this).hasClass("active")) {
                return false;
            }

            var status = $(this).attr("data-status");

            $("#my-order ul li").each(function() {
                $(this).removeClass("active");
            });

            $(this).addClass("active");

            getOrderList(status);

        });

        getOrderList(-1);

    });


</script>
<div class="container" id="container">
    <div class = "search">
        <div class="order-add">
            <img class="icon-add" src="/Template/images/icon-addOrder.png" alt="" v-on:click="addWorkorder()">
        </div>
        <div class="date-search">
            <input type="text" style="display: none;" id="workorderType" value="{$type}">
            <input id="startdate" class="date-start" name="startdate" type="date" placeholder="开始日期">
            <input id="enddate" class="date-end" name="enddate" type="date" placeholder="结束日期">
            <img name="refreshImg" class="icon-refreshDate" src="/Template/images/icon-refreshDate.png" alt="" v-on:click="dateRefresh()">
            <img name="searchImg" class="icon-searchDate" src="/Template/images/icon-searchDate.png" alt="" v-on:click="dateSearch()">
        </div>
    </div>
    <div id="my-order">
        <ul>
            <li class="active" data-status="-1">
                <span>未提交</span>
            </li>
            <if condition="$type neq '3'">
                <li data-status="1">
                    <span>出处方</span>
                </li>
                <li data-status="2">
                    <span>已派单</span>
                </li>
                <li data-status="3">
                    <span>制作中</span>
                </li>
            </if>
            <li data-status="4">
                <span>已完成</span>
            </li>
            <li data-status="0">
                <span>全部</span>
            </li>
        </ul>
    </div>
    <div class="order-detail">
        <div class="no-data" v-if="orderList == null">暂无数据</div>
        <div class="order-info" v-for="order in orderList">
            <div v-on:click="editWorkorder(order.workorder_id)">
                <div class="status active1" v-if="order.status == -1">
                    <img src="/Template/images/icon-waiting.png" alt="">
                    <span class="status-content">未提交</span>
                </div>
                <div class="status active1" v-if="order.status == 1">
                    <img src="/Template/images/icon-processing.png" alt="">
                    <span class="status-content">处理中</span>
                </div>
                <div class="status active1" v-if="order.status == 2">
                    <img src="/Template/images/icon-waiting.png" alt="">
                    <span class="status-content">已派单</span>
                </div>
                <div class="status active1" v-if="order.status == 3">
                    <img src="/Template/images/icon-produce.png" alt="">
                    <span class="status-content">制作中</span>
                </div>
                <div class="status active1" v-if="order.status == 4">
                    <img src="/Template/images/icon-clock.png" alt="">
                    <span class="status-content">已完成</span>
                </div>

                <div class="have-padding">
                    <div class="user-order-info">
                        <div class="ui-item pickUp-info">
                            <span class="item-left">工单号</span>
                            <span class="item-right">{{order.workorder_no}} {{order.side}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status == -1">
                            <span class="item-left">创建人</span>
                            <span class="item-right">{{order.creator}}：{{order.create_time}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status != -1">
                            <span class="item-left">销售</span>
                            <span class="item-right">{{order.sales}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status != -1">
                            <span class="item-left">下单人</span>
                            <span class="item-right">{{order.creator}}：{{order.update_time}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status > 2">
                            <span class="item-left">检测人</span>
                            <span class="item-right">{{order.examinator}}：{{order.exam_time}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status != -1">
                            <span class="item-left">处方人</span>
                            <span class="item-right">{{order.prescriber}}：{{order.prescribe_time}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status > 2">
                            <span class="item-left">矫形器类型</span>
                            <span class="item-right">{{order.type_name}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status > 2">
                            <span class="item-left">价格</span>
                            <span class="item-right">{{order.price}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status == 3">
                            <span class="item-left">预付款</span>
                            <span class="item-right">{{order.deposit}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status == 3">
                            <span class="item-left">预计交付</span>
                            <span class="item-right">{{order.delivery_date}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status == 4">
                            <span class="item-left">交付时间</span>
                            <span class="item-right">{{order.end_time}}</span>
                        </div>
                        <div class="ui-item pickUp-info">
                            <span class="item-left" >患者资料</span>
                            <span v-if="order.status < 2">
                                <img class="item-img" v-if="order.patient_completed == -1" src="/Template/images/icon-error.png" alt="">
                                <img class="item-img" v-if="order.patient_completed == 1" src="/Template/images/icon-ok.png" alt="">
                                <img class="item-img-warn" v-if="order.patient_completed == null" src="/Template/images/icon-warn.png" alt="">
                            </span>
                            <span class="item-right" v-if="order.patient_completed == 1">{{order.patient_name}}，{{order.sex}}，{{order.age}}岁</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status < 4 && order.workorder_type != 3">
                            <span class="item-left" >检测评估</span>
                            <span v-if="order.status < 2">
                                <img class="item-img" v-if="order.exam_basic_completed == -1" src="/Template/images/icon-error.png" alt="">
                                <img class="item-img" v-if="order.exam_basic_completed == 1" src="/Template/images/icon-ok.png" alt="">
                                <img class="item-img-warn" v-if="order.exam_basic_completed == null" src="/Template/images/icon-warn.png" alt="">
                            </span>
                            <span class="item-right" v-if="order.exam_basic_completed != null">{{order.exam_basic_update_time}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status < 4 ">
                            <span class="item-left" >物理检查</span>
                            <span v-if="order.status < 2">
                                <img class="item-img" v-if="order.exam_basic_cp_completed == -1" src="/Template/images/icon-error.png" alt="">
                                <img class="item-img" v-if="order.exam_basic_cp_completed == 1" src="/Template/images/icon-ok.png" alt="">
                                <img class="item-img-warn" v-if="order.exam_basic_cp_completed == null" src="/Template/images/icon-warn.png" alt="">
                            </span>
                            <span class="item-right" v-if="order.exam_basic_cp_completed != null">{{order.exam_basic_cp_update_time}}</span>
                        </div>
                        <div class="ui-item pickUp-info" v-if="order.status < 4 && order.workorder_type != 3">
                            <span class="item-left" >检查测量</span>
                            <span v-if="order.status < 2">
                                <img class="item-img" v-if="order.exam_measure_completed == -1" src="/Template/images/icon-error.png" alt="">
                                <img class="item-img" v-if="order.exam_measure_completed == 1" src="/Template/images/icon-ok.png" alt="">
                                <img class="item-img-warn" v-if="order.exam_measure_completed == null" src="/Template/images/icon-warn.png" alt="">
                            </span>
                            <span class="item-right" v-if="order.exam_measure_completed != null">{{order.exam_measure_update_time}}</span>
                        </div>

                        <!--div class="ui-item pickUp-info" v-if="order.status < 4 && order.workorder_type == 2">
                            <span class="item-left" >侧弯绘制</span>
                            <span v-if="order.status < 2">
                                <img class="item-img" v-if="order.exam_measure_completed == -1" src="/Template/images/icon-error.png" alt="">
                                <img class="item-img" v-if="order.exam_measure_completed == 1" src="/Template/images/icon-ok.png" alt="">
                                <img class="item-img-warn" v-if="order.exam_measure_completed == null" src="/Template/images/icon-warn.png" alt="">
                            </span>
                            <span class="item-right" v-if="order.exam_measure_completed != null">{{order.exam_measure_update_time}}</span>
                        </div-->
                        <!--div class="ui-item pickUp-info">
                            <span class="item-left">处方
                                <img class="item-img" v-if="order.exam_analysis_completed == -1" src="/Template/images/icon-error.png" alt="">
                                <img class="item-img" v-if="order.exam_analysis_completed == 1" src="/Template/images/icon-ok.png" alt="">
                                <img class="item-img-warn" v-if="order.exam_analysis_completed == null" src="/Template/images/icon-warn.png" alt="">
                            </span>
                            <span class="item-right" v-if="order.exam_analysis_completed != null">更新时间：{{order.exam_analysis_update_time}}</span>
                        </div-->
                    </div>
                </div>
            </div>
        </div>

    </div>

</div>

<include file="./Template/footer.html" />

